﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="newClass.aspx.cs" Inherits="Staff_newClass" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">

        .style1
        {
            font-family: 微軟正黑體;
            font-size: xx-large;
        }
        .style2
        {
            text-align: center;
        }
        .style3
        {
            width: 72%;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div class="style2">
    
        <span class="style1">開設新班</span><br />
        <br />
        <table align="center" class="style3">
            <tr>
                <td>
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td colspan="2">
                    <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" 
                        BackColor="White" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" 
                        CellPadding="3" DataKeyNames="DepartmentId" DataSourceID="SqlDataSource1" 
                        DefaultMode="Insert" GridLines="Horizontal" Height="50px" Width="355px">
                        <AlternatingRowStyle BackColor="#F7F7F7" />
                        <EditRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
                        <Fields>
                            <asp:BoundField DataField="DepartmentId" HeaderText="DepartmentId" 
                                InsertVisible="False" ReadOnly="True" SortExpression="DepartmentId" />
                            <asp:BoundField DataField="DepartmentName" HeaderText="新班名稱" 
                                SortExpression="DepartmentName" />
                            <asp:BoundField DataField="Intro" HeaderText="院別" SortExpression="Intro" />
                            <asp:CommandField ButtonType="Button" ShowInsertButton="True" />
                        </Fields>
                        <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
                        <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
                        <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
                        <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
                    </asp:DetailsView>
                </td>
            </tr>
            <tr>
                <td>
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td colspan="2">
                    <asp:GridView ID="GridView1" runat="server" AllowSorting="True" 
                        AutoGenerateColumns="False" CellPadding="4" DataKeyNames="DepartmentId" 
                        DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None" 
                        Width="376px">
                        <AlternatingRowStyle BackColor="White" />
                        <Columns>
                            <asp:BoundField DataField="DepartmentId" HeaderText="編號" InsertVisible="False" 
                                ReadOnly="True" SortExpression="DepartmentId" />
                            <asp:BoundField DataField="DepartmentName" HeaderText="班級名稱" 
                                SortExpression="DepartmentName" />
                            <asp:BoundField DataField="Intro" HeaderText="院別" SortExpression="Intro" />
                            <asp:CommandField ButtonType="Button" ShowEditButton="True" />
                        </Columns>
                        <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
                        <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
                        <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
                        <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
                        <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
                        <SortedAscendingCellStyle BackColor="#FDF5AC" />
                        <SortedAscendingHeaderStyle BackColor="#4D0000" />
                        <SortedDescendingCellStyle BackColor="#FCF6C0" />
                        <SortedDescendingHeaderStyle BackColor="#820000" />
                    </asp:GridView>
                </td>
            </tr>
        </table>
        <br />
        <br />
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ProjectConnectionString %>" 
            DeleteCommand="DELETE FROM [Department] WHERE [DepartmentId] = @DepartmentId" 
            InsertCommand="INSERT INTO [Department] ([DepartmentName], [Intro]) VALUES (@DepartmentName, @Intro)" 
            SelectCommand="SELECT * FROM [Department]" 
            UpdateCommand="UPDATE [Department] SET [DepartmentName] = @DepartmentName, [Intro] = @Intro WHERE [DepartmentId] = @DepartmentId">
            <DeleteParameters>
                <asp:Parameter Name="DepartmentId" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="DepartmentName" Type="String" />
                <asp:Parameter Name="Intro" Type="String" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="DepartmentName" Type="String" />
                <asp:Parameter Name="Intro" Type="String" />
                <asp:Parameter Name="DepartmentId" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
    
    </div>
    </form>
</body>
</html>
